/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.ui.utils;

import java.util.HashSet;
import java.util.Set;

public class ColoredRanges
{
	private Set<ColoredRange> ranges;
	
	public ColoredRanges()
	{
		this.ranges = new HashSet<ColoredRange>();
	}
	
	public void addRange(ColoredRange cr)
	{
		this.ranges.add(cr);
	}
	
	public void removeRange(ColoredRange cr)
	{
		this.removeRange(cr);
	}
	
	public ColoredRange getRange(int v)
	{

		for(ColoredRange cr:this.ranges)
		{
			if (cr.isRightColor(v))
				return cr;
		}
		return null;
	}
	
	public Set<ColoredRange> getRanges(int v)
	{
		HashSet<ColoredRange> res = new HashSet<ColoredRange>();
		for(ColoredRange cr:this.ranges)
		{
			if (cr.isRightColor(v))
				res.add(cr);
		}
		return res;
	}
}
